#!/bin/bash
##################################################################
## function: compress log 
## eg：./log_compress.sh 20150908 20150908
## author: shx
## createdate: 20150908 
## version:     
################################################################## 
. /home/hadoop/shx/baseUtil.sh


if [[ ! -n "$1" ]] && [[ ! -n "$2" ]] ;then
	startDate=`date -d '-1 days'  +%Y%m%d`
	endDate=`date -d '-1 days' +%H`
else
	startDate=$1
	endDate=$2
fi

#获取时间循环列表
startSec=`date -d "$startDate" "+%s"`
endSec=`date -d "$endDate" "+%s"`

for((i=startSec;i<=endSec;i+=86400)); do
    curdate=`date -d "@$i" "+%Y%m%d"`
    echo $curdate

  for((k=0;k<=23;k++));
  do  
    fhour=$k
    if [[ $k -lt 10 ]]; then
      fhour='0'$k
    fi
    echo "================"$curdate" "$fhour

    /usr/local/cloud/hadoop/bin/hadoop jar  qyer_compress.jar /flume/original/track/$curdate/$fhour/*  /flume/originalcompress/track/$curdate/$fhour
    /usr/local/cloud/hadoop/bin/hadoop jar  qyer_compress.jar /flume/original/apptrack/$curdate/$fhour/*  /flume/originalcompress/apptrack/$curdate/$fhour
    /usr/local/cloud/hadoop/bin/hadoop jar  qyer_compress.jar /flume/original/api_response/$curdate/$fhour/*  /flume/originalcompress/api_response/$curdate/$fhour
    /usr/local/cloud/hadoop/bin/hadoop jar  qyer_compress.jar /flume/original/nobita/$curdate/$fhour/*  /flume/originalcompress/nobita/$curdate/$fhour
    /usr/local/cloud/hadoop/bin/hadoop jar  qyer_compress.jar /flume/original/timecost/$curdate/$fhour/*  /flume/originalcompress/timecost/$curdate/$fhour

  done
done

if [ $? -eq 0 ]
  then
  	echo `date`"=============== log compress is ok  end===============" 
else
  	echo `date`"================log compress is error end !================" 
  	mailSend "127 :log compress is error end !"
fi








